MAKESYSVER=" 1.3 "

SYSTEM:=${shell uname}
ifeq ($(SYSTEM),Linux)
   LINUXGCC = 1
   CYGPATH = $1
else
   CYGPATH = "$(shell cygpath -w $1)"
endif


-include $(MK_DIR)/local.mk

ifndef OUTPUT_DIRECTORY
   $(error "OUTPUT_DIRECTORY" variable is not set. PLS update local.mk)
else
   export OUTPUT_DIR   := $(OUTPUT_DIRECTORY)
   export OUTPUT_CLEAN := $(OUTPUT_DIRECTORY)
endif


#-------------------------------
# Export major parameters
#-------------------------------
ifndef GL_COMPILER
   export GL_COMPILER = $(COMPILER)
endif

ifndef GL_CPUTYPE
   export GL_CPUTYPE  = $(CPUTYPE)
endif

ifndef GL_CHIP
   export GL_CHIP     = $(CHIP)
endif


#-------------------------------
# CPU Mapping
#-------------------------------
ifdef GL_CHIP
   #ARM devices
   ifeq ($(GL_CHIP),STR912)
      export GL_CPUTYPE  = ARM966E-S
   endif
   ifeq ($(GL_CHIP),OMAP2420)
      export GL_CPUTYPE  = 4T
   endif
   ifeq ($(GL_CHIP),LPC2378)
      export GL_CPUTYPE  = ARM7TDMI
   endif
   ifeq ($(GL_CHIP),STM32F103)
      export GL_CPUTYPE  = CORTEX-M3
   endif
   ifeq ($(GL_CHIP),LPC1778)
      export GL_CPUTYPE  = CORTEX-M3
   endif
   ifeq ($(GL_CHIP),LPC1768)
      export GL_CPUTYPE  = CORTEX-M3
   endif


   #PIC devices
   ifeq ($(GL_CHIP),PIC18F4550)
      export GL_CPUTYPE  = 18F4550
   endif

   #MSP430 devices
   ifeq ($(GL_CHIP),MSP430X5XX)
      export GL_CPUTYPE  = MSP430
   endif

endif


-include $(MK_DIR)/compiler*.mk


#-------------------------------
# Other parameters
#-------------------------------

ifdef OUTPUT_DIR
   OUTPUT_DIR_SLASH = $(OUTPUT_DIR)/
endif


OUTDIR          = _out_
OUTPUT_FILENAME = $(OUTDIR)/output.$(OUTFILEEXT)
OUTPUT_RAWFILE  = $(OUTDIR)/output.raw
OUTPUT_HEXFILE  = $(OUTDIR)/output.hex
OUTPUT_INFFILE  = $(OUTDIR)/output.info
OUTPUT_MAPFILE  = $(OUTDIR)/output.map
LIB_FILENAME    = $(OUTDIR)/lib.$(LIBEXT)
DECO            = "[\#\#\#\#\#] "


#-------------------------------
#  Terminal Colors
#-------------------------------
ifndef NOCOLORS
   CL_BRIGHT =printf '\033[1m'
   CL_BLACK  =printf '\033[30m'
   CL_RED    =printf '\033[31m'
   CL_GREEN  =printf '\033[32m'
   CL_YELLOW =printf '\033[33m'
   CL_BLUE   =printf '\033[34m'
   CL_MAGENTA=printf '\033[35m'
   CL_CYAN   =printf '\033[36m'
   CL_WHITE  =printf '\033[37m'
   CL_RESET  =printf '\033[0m'

   COL_DECO  = $(CL_RESET);$(CL_WHITE)
   COL_LIB   = $(CL_BRIGHT);$(CL_YELLOW)
   COL_LINK  = $(CL_BRIGHT);$(CL_RED)
   COL_COMP  = $(CL_BRIGHT);$(CL_GREEN)
   COL_BALL  = $(CL_BRIGHT);$(CL_YELLOW)
   COL_CLEAN = $(CL_RESET);$(CL_WHITE)
   COL_RESET = $(CL_BRIGHT);$(CL_WHITE)
   COL_DONE  = $(CL_BRIGHT);$(CL_BLUE)
else
   CL_BRIGHT = echo -n
   CL_BLACK  = echo -n
   CL_RED    = echo -n
   CL_GREEN  = echo -n
   CL_YELLOW = echo -n
   CL_BLUE   = echo -n
   CL_MAGENTA= echo -n
   CL_CYAN   = echo -n
   CL_WHITE  = echo -n
   CL_RESET  = echo -n

   COL_DECO  = echo -n
   COL_LIB   = echo -n
   COL_LINK  = echo -n
   COL_COMP  = echo -n
   COL_BALL  = echo -n
   COL_CLEAN = echo -n
   COL_RESET = echo -n
   COL_DONE  = echo -n
endif